Skip to content

Feat/compt 83 testing suite#24

Closed
saadmoumou wants to merge 2 commits intodevelopfrom
feat/COMPT-83-testing-suite
Closed

Feat/compt 83 testing suite#24
saadmoumou wants to merge 2 commits intodevelopfrom
feat/COMPT-83-testing-suite

Conversation

@saadmoumou
Copy link
Copy Markdown
Contributor

Summary

  • What does this PR change?

Why

  • Why is this change needed?

Checklist

  • Added/updated tests (if behavior changed)
  • npm run lint passes
  • npm run typecheck passes
  • npm test passes
  • npm run build passes
  • Added a changeset (npx changeset) if this affects consumers

Notes

  • Anything reviewers should pay attention to?

@saadmoumou saadmoumou requested a review from a team as a code owner April 2, 2026 14:43
Copilot AI review requested due to automatic review settings April 2, 2026 14:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the @ciscode/health-kit module’s public API and module registration options while expanding the test suite and tightening coverage thresholds.

Changes:

  • Renames the HealthCheckResult response field from indicators to results.
  • Adds HealthKitModule.registerAsync() and makes register() options more optional/defaulted.
  • Removes the Mongo indicator implementation/tests and adjusts package metadata (Postgres-focused) and Jest coverage thresholds.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/services/health.service.ts Renames HealthCheckResult.indicators to results (public API response change).
src/services/health.service.spec.ts Updates tests to assert results instead of indicators.
src/controllers/health.controller.spec.ts Updates controller tests to mock results instead of indicators.
src/health-kit.module.ts Adds registerAsync(), defaults path to "health", refactors provider wiring.
src/health-kit.module.spec.ts Adds module-level tests for registration behavior and DI indicator routing.
src/index.ts Exports HealthModuleAsyncOptions and removes Mongo indicator exports.
src/indicators/mongo.indicator.ts Removes Mongo health indicator implementation.
src/indicators/mongo.indicator.spec.ts Removes Mongo indicator unit tests.
package.json Updates description, adds optional peer dep @nestjs/terminus.
jest.config.ts Raises global Jest coverage thresholds from 80% to 85%.

Comment on lines 7 to 10
export interface HealthCheckResult {
status: "ok" | "error";
indicators: HealthIndicatorResult[];
results: HealthIndicatorResult[];
}
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming the public HealthCheckResult field from indicators to results is a breaking change for both runtime responses and TypeScript consumers. Consider keeping indicators as a deprecated alias (or returning both) until a major version bump, and ensure the package version/changeset reflects the breaking API change.

Copilot uses AI. Check for mistakes.
Comment thread src/health-kit.module.ts
Comment on lines +63 to +66
static register(options: HealthModuleOptions = {}): DynamicModule {
const { path = "health", liveness = [], readiness = [], indicators = [] } = options;
const { indicatorProviders, livenessClasses, readinessClasses } =
HealthKitModule._resolveIndicatorClasses(indicators);
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module-level JSDoc @example above still imports/uses MongoHealthIndicator, but the Mongo indicator/export was removed in this PR. Please update that example to a supported indicator (e.g., Postgres) or a custom indicator so consumers don’t copy/paste broken code.

Copilot uses AI. Check for mistakes.
Comment thread src/health-kit.module.ts
Comment on lines +33 to +36
/** Factory that returns liveness/readiness/indicators options. */
useFactory: (
...args: unknown[]
) => Promise<Omit<HealthModuleOptions, "path">> | Omit<HealthModuleOptions, "path">;
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HealthModuleAsyncOptions.useFactory is documented/typed as returning "liveness/readiness/indicators" options, but registerAsync() cannot honor indicators returned from the factory (providers must be registered up front from options.indicators). Consider changing the return type/documentation to omit indicators (and possibly path) to avoid suggesting unsupported configuration.

Suggested change
/** Factory that returns liveness/readiness/indicators options. */
useFactory: (
...args: unknown[]
) => Promise<Omit<HealthModuleOptions, "path">> | Omit<HealthModuleOptions, "path">;
/** Factory that returns liveness/readiness options (no indicators). */
useFactory: (
...args: unknown[]
) => Promise<Omit<HealthModuleOptions, "path" | "indicators">> | Omit<HealthModuleOptions, "path" | "indicators">;

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +18
// ÔöÇÔöÇ Fixtures ÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇ

Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The section divider comments contain garbled characters ("ÔöÇ"), which looks like a bad encoding/transcoding artifact and hurts readability/searchability. Replace these with plain ASCII (e.g., // --- Fixtures ---) or remove them.

Copilot uses AI. Check for mistakes.
Comment on lines +101 to +105
const liveness = module.get<HealthIndicatorResult[]>(HEALTH_LIVENESS_INDICATORS);
expect(liveness).toHaveLength(1);

const readiness = module.get<HealthIndicatorResult[]>(HEALTH_READINESS_INDICATORS);
expect(readiness).toHaveLength(0);
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These DI tokens (HEALTH_LIVENESS_INDICATORS / HEALTH_READINESS_INDICATORS) provide arrays of indicator instances (IHealthIndicator[]/BaseHealthIndicator[]), but the test retrieves them as HealthIndicatorResult[]. Using the correct type here will prevent confusion and type-unsafe usage in future test edits.

Copilot uses AI. Check for mistakes.
Comment thread package.json
Comment on lines +48 to +56
"@nestjs/terminus": "^10 || ^11",
"reflect-metadata": "^0.2.2",
"rxjs": "^7"
},
"peerDependenciesMeta": {
"@nestjs/terminus": {
"optional": true
}
},
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nestjs/terminus is added as an (optional) peer dependency, but there are no imports/usages of it in the codebase. Unless you’re intentionally declaring compatibility, consider removing it to avoid unnecessary dependency management for consumers.

Suggested change
"@nestjs/terminus": "^10 || ^11",
"reflect-metadata": "^0.2.2",
"rxjs": "^7"
},
"peerDependenciesMeta": {
"@nestjs/terminus": {
"optional": true
}
},
"reflect-metadata": "^0.2.2",
"rxjs": "^7"
},

Copilot uses AI. Check for mistakes.
Comment thread src/index.ts

export { RedisHealthIndicator } from "./indicators/redis.indicator";
export type { RedisClient } from "./indicators/redis.indicator";

Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing MongoHealthIndicator / MongoDb from the public exports is a breaking change for consumers. If the removal is intentional, ensure the release is handled as a breaking change (major version + changeset/changelog); otherwise, consider keeping the export (or providing a migration path).

Suggested change
export { MongoHealthIndicator } from "./indicators/mongo.indicator";
export type { MongoDb } from "./indicators/mongo.indicator";

Copilot uses AI. Check for mistakes.
@saadmoumou saadmoumou force-pushed the feat/COMPT-83-testing-suite branch from bb09dec to f316894 Compare April 2, 2026 14:59
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 2, 2026

@saadmoumou saadmoumou closed this Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants